home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / editor / dedupe12.zip / TECH.DOC < prev    next >
Text File  |  1997-05-12  |  4KB  |  60 lines

  1.   "DeDupe" Tecnical Information:
  2.  
  3.   Before I begin, "Source" is actually Reference. "Source Block", "Block2",
  4. "Source Line" (the Reference Line), and "Line2" (the Line that the Reference
  5. Line is Compared To) are All part of the Same File, which is Opened Twice.
  6. The Same File is Opened as the "Source" File, and again as "File2".
  7.  
  8.   I thought the Best Way to Remove Duplicate Lines Located Anywhere would be
  9. to "Read" (Load) the File by Blocks.  "Source" Line 1 is Compared to Line 2,
  10. then to Line 3, ...... then to the Last Line of the Current Block.  Next
  11. "Source" Line 2 is Compared to Line 3, then to Line 4...... then to the Last
  12. Line of the Current Block.  Next "Source" Line 3, etc.  The "Source" Line is
  13. Always Lower than "Line2" (the Line Compared To).   When all the "Source"
  14. Lines of the Current "Source" Block are Finished, Load the Next "Block2" and
  15. Reset "Source" Block back to Line 1 again.  Now Compare "Source" Line 1 to
  16. the first Line in the next "Block2" (the next Block of the File).  When
  17. "Block2" is the Last Block of the File ("File2"), and all the "Source" Block
  18. Lines have been Compared to All the Lines in the Last "Block2", ReStart
  19. "File2" again and Advance "Source" Block to the Next Block of the File.
  20. Note: Until now, the "Source" Block has been the First Block of the File.
  21. Advance "File2" Lines (ReStarted "File2") until "Line2" is Past the Current
  22. "Source" Line (Now in the Next Block of the File), then resume Comparing
  23. Lines.
  24.  
  25.    This Process Ends when the "Source" Block reaches the Last Block of the
  26. File, and All "Source" Lines, except the Last Line (Can't Compare to the
  27. Same Line in the Same Block) are Compared.
  28.  
  29.    But wait, it's Not Over yet!  Along the way, the Lines Compared that
  30. Match (Duplicate) are Marked (Setting a Bit) in a "Mark" Segment in Computer
  31. Memory.  One final Pass Reads the entire File again, using a Line Counter,
  32. which is used to "Index" the Related Bit in the "Mark" Segment to the
  33. Relative Line of the File, in order to determine if the Line is a Duplicate
  34. or Not.
  35.  
  36.   This Process made the Project Complex, but the Alternative was to Limit
  37. the Size of the File from Small to Medium size (whatever can Fit into
  38. available Memory), or to Load the First Line and Compare it to Every Line
  39. (from Line 2) to the End of the File.  Next, Line 2, to Every Line (from
  40. Line 3) to the End of the File.  This would have made my "Project" Easier,
  41. but for a 30,000 Line File, the File would have to be Read (Loaded) 30,000
  42. times, which is a good way to Shorten the Life of your Hard Drive.
  43.  
  44.   WHY IT TAKES "TIME":
  45.  
  46.   I did Not know, when I started this Project, how many Line Compares would
  47. take place.  Test Procedures added to the Program, while it was under
  48. Development, included a "Cycle Counter", which Counted every time a Line
  49. Comparison took Place.  I never imagined the Astronomical Number of Times
  50. Lines would be Compared in a Large File.  A 301 Line File (Small File)
  51. required a Total of 45,150 Compare Cycles.  If you Add just 10 Lines to that
  52. File, it Jumps to 48,205 Cycles, an Increase of 3,055 Cycles.  If you Add
  53. another 10 Lines (Now 321 Lines), the Total Cycles Increased to 51,360, an
  54. additional increase of 3,155.  Notice the differences also Increased (Non-
  55. Linear).  Now Imagine a 20,000 Line File!  This is the Reason it took about
  56. 12 minutes on my 75Mhz Pentium PC.  Note: Two different 20,000 Line Files
  57. will Not take the Same amount of Time.  It depends on the number of
  58. Characters in the Lines and how far into each line before a Mis-Match occurs
  59. (move on to the next Line).
  60.